﻿Public Class ProjectWebForm

    Public ReadOnly Property WebBrowser() As WebBrowser
        Get
            Return Me.wbMain
        End Get
    End Property

    Private Sub ProjectWebForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.CenterToParent()
        'todo.. temp revise 
        Me.wbMain.Navigate(My.MySettings.Default.PrjWebURL)
    End Sub

    Private Sub ShowLoading_Main()
        Me.wbMain.Visible = False
        Me.pnlLoading.Visible = True
    End Sub

    Private Sub ShowWeb_Main()
        Me.pnlLoading.Visible = False
        Me.wbMain.Visible = True
    End Sub

    Private Sub ShowLoading()
        Me.pnlLoading.Visible = True
    End Sub

    Private Sub HideLoading()
        Me.pnlLoading.Visible = False
    End Sub

    Private Sub wbMain_Navigating(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles wbMain.Navigating
        If e.Url.AbsoluteUri.Equals(My.Settings.PrjWebURL) Then
            ShowLoading_Main()
        Else
            ShowLoading()
        End If
    End Sub

    Private Sub wbMain_Navigated(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles wbMain.Navigated
        If e.Url.AbsoluteUri.Equals(My.Settings.PrjWebURL) Then
            ShowWeb_Main()
        Else
            HideLoading()
        End If
    End Sub

    Private Sub wbMain_ProgressChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles wbMain.ProgressChanged
        Me.pbLoading.Value = e.CurrentProgress / e.MaximumProgress * Me.pbLoading.Maximum
    End Sub

    Private Sub wbMain_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles wbMain.DocumentCompleted
        'Dim tt = Me.wbMain.Document
    End Sub

End Class